<template>
  <div id="app">
    <div id="nav">
      <router-link to="/">Home</router-link> |
      <router-link to="/about">About</router-link>
    </div>
    <router-view/>
    <div v-for="(item, index) in mockData" :key="index">
      <p>{{item.title}}</p>
      <p>{{item.date}}</p>
      <img :src="item.thumbnail_pic_s" alt=""/>
    </div>
  </div>
</template>

<script>
import axios from 'axios'
import {getUser} from './axios/user'
const user = () => {
    return new Promise((resolve, reject) => {
      axios.get('/users').then(res => {
          resolve(res.data)
      })
    })
}
// const mockData = () => {
//   return new Promise((resolve, reject) => {
//     axios.post('/news/index').then(res => {
//       resolve(res.data)
//     })
//   })
// }
export default {
  name: 'app',
  data() {
    return {
      mockData: []
    }
  },
  mounted() {
    this.getUser()
  },
  methods: {
    async getUser () {
      // let data = await user()
      let mock = await getUser()
      // this.mockData = mock.articles
      console.log(mock.data)
    }
  }
}
</script>

<style>
  #app {
    font-family: 'Avenir', Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-align: center;
    color: #2c3e50;
    margin-top: 60px;
  }
</style>
